package br.quest.utils;

import android.content.Context;
import android.widget.Toast;

public class Utils {

    public static void showShortToast(Context ctx, String msg) {
        Toast.makeText(ctx, msg, Toast.LENGTH_SHORT).show();
    }

    public static void showLongToast(Context ctx, String msg) {
        Toast.makeText(ctx, msg, Toast.LENGTH_LONG).show();
    }

    /**
     * Transform a double number to a formatted string. The resulting string will have as many decimal places to the
     * right of the decimal mark as specified.
     * 
     * @param number The number to be formatted.
     * @param places The number of decimal places to have in the resulting string.
     * @return A formatted string representing the number. eg.: calling with the number PI and 5 decimal places will
     *         output "3.14159"
     */
    public static String formatDecimalPlaces(double number, int places) {
        double coef = Math.pow(10, places);
        return (((int) (number * coef)) / coef) + "";
    }

}
